package com.example.test.config;

import com.example.test.annotation.NoThanks;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 全局切面管理,主要用来token验证
 * @ClassName: 林文峰
 * @Author Administrator
 * @Date 2020/6/17 0017
 */
@Aspect
@Component
public class GlobalAop {

	@Pointcut("execution(* com.example.test.controller.*.*(..))")
	public void controllerPoint(){}

//	@Before("controllerPoint()")
//	public void doBefore(JoinPoint joinPoint) throws NoSuchMethodException {
//		String name = joinPoint.getTarget().getClass().getSimpleName();
//		String name1 = joinPoint.getSignature().getName();
//		NoThanks annotation1 = joinPoint.getTarget().getClass().getMethod(joinPoint.getSignature().getName()).getAnnotation(NoThanks.class);
//		NoThanks annotation = joinPoint.getTarget().getClass().getAnnotation(NoThanks.class);
//		if (annotation != null){
//			System.out.println(name+": 不是很行");
//		}
//		if (annotation1 != null){
//			System.out.println(name+": 还是可以");
//		}
//		System.out.println("是真的");
//		System.out.println(name+": "+name1);
//	}
}
